1. Technical Field
The present invention relates to intermediate language expressions in a compiler of computer system. In particular, the present invention relates to a programming framework for pattern matching and transformation of intermediate language expression trees in a compiler of a computer system.
2. Description of Related Art
Typically, when the source code of a program is compiled using a compiler, the latter parses the source program and generates an intermediate representation for the program. An example of a compiler is an IBM XL compiler and an example of a generated intermediate representation is W-code.
The intermediate representation provides a stack-based representation of expressions in the program.
Pattern matching of intermediate representation is a common technique used to locate predictable statements and expressions and retrieve specific elements, in order to create derived expressions.
Pattern matching of intermediate representation helps to identify a loop that has such induction variable, which adds a constant value to x for every iteration of the loop. Therefore, pattern matching of intermediate representation is a useful technique in loop optimization.
However, most existing pattern matching code is hand crafted for specific patterns. While a generalized pattern matching code or pattern matcher for a given pattern may be written, it is cumbersome for the programmer. In addition, existing pattern matcher code does not provide the capability of easily constructing complex pattern matchers and pattern transformers as objects using grammatical building blocks.
Therefore, the ability to construct and pass these constructed objects as parameters to functions to perform pattern matching and transformation, as well as embedding these constructed objects within a program is desirable. Furthermore, the extensibility of the pattern matcher is desired, such that performance of the compiler may be improved with embedded pattern matchers.
U.S. patent application Ser. Nos. 11/075,091 and 10/929,175 disclose an expression matching and transformation programming framework (EMTF). These applications disclose a method, apparatus, and computer program product for pattern matching of intermediate representation and transformation of intermediate language expression trees, such that pattern matching can be embedded within a source program. However, the technology so disclosed does not allow nesting searches within one-another, resulting in limited flexibility of the framework to handle more complex patterns.
Therefore, it would be advantageous to have an improved method, apparatus, and computer program product for easy pattern matching of intermediate representation and transformation of intermediate language expression trees, such that pattern matching allows nesting searches and transforms within one-another, and can be embedded within a source program.